#include "wx/wx.h"

class App : public wxApp {
private:
    bool OnInit() override;
};

IMPLEMENT_APP(App);

class Frame : public wxFrame {
public:
    explicit Frame(wxString const& title);

    void OnAbout(wxCommandEvent& event)
    {
        wxString msg;

        msg.Printf(wxT("Hello, this is wx sample, built under `%s'"),
            wxVERSION_STRING);

        wxMessageBox(msg, wxT("About"),
            wxOK | wxICON_INFORMATION, this);
    }

    void OnQuit(wxCommandEvent& event) { Close(); }

private:
    DECLARE_EVENT_TABLE();
};

// clang-format off
BEGIN_EVENT_TABLE(Frame, wxFrame)
    EVT_MENU(wxID_ABOUT, Frame::OnAbout)
    EVT_MENU(wxID_EXIT, Frame::OnQuit)
END_EVENT_TABLE()
// clang-format on

Frame::Frame(wxString const& title)
    : wxFrame(NULL, wxID_ANY, title)
{
    // SetIcon(wxIcon(mondrian_xpm));

    wxMenu* file_menu = new wxMenu();

    file_menu->Append(wxID_EXIT, wxT("Exit\tAlt-X"),
        wxT("Quit this application"));

    wxMenu* help_menu = new wxMenu();

    help_menu->Append(wxID_ABOUT, wxT("&About...\tF1"),
        wxT("Show about dialog"));

    wxMenuBar* bar = new wxMenuBar();

    bar->Append(file_menu, wxT("&File"));
    bar->Append(help_menu, wxT("&Help"));

    SetMenuBar(bar);

    CreateStatusBar(2);
    SetStatusText(wxT("Welcome"));
}

bool App::OnInit()
{
    Frame* frame = new Frame(wxT("Minimal wxWidgets App"));

    frame->Show(true);
    return true;
}

// int main() { return 0; }
